/** 
 * @Description: 文件描述
 * @Author: 程前
 * @Date: 2025-02-11 09:09:51
 * @LastEditors: 程前
 * @LastEditTime: 2025-02-17 16:06:13
 */
import { Viewer, Cartesian3, Color, Entity } from "cesium";
import { getAssetsFile } from "@/utils";
import Roaming from "./Roaming";

export default class RoamingExemple {
    private viewer: Viewer
    private roaming: Roaming
    private radarEntity: Entity | null

    constructor(viewer: Viewer) {
        this.viewer = viewer
    }

    public async initEvents() {
        this.viewer.scene.debugShowFramesPerSecond = true;
        this.roaming = new Roaming(this.viewer, { time: 30 });
        // 获取path.json的数据
        const res = await fetch('/interpolationPath.json')
        const path = await res.json()
        let arr = path.features[0].geometry.coordinates;
        let lines = []
        arr.forEach((item: number[]) => {
            lines.push(Cartesian3.fromDegrees(item[0], item[1], 1000))
        })
        this.roaming.modelRoaming({
            model: {
                uri: getAssetsFile('cesium/models/Cesium_Air.glb'),
                scale: 30,
                silhouetteSize: 2, //边框大小
                silhouetteColor: Color.fromCssColorString("#001aff"), //边框
            },
            Lines: lines,
            path: {
                show: true,
            },
            polyline: {
                show: false,
                material: Color.RED
            },
        })

    }

    public destroy() {
        this.roaming.destroy()
    }
}

